package com.uci.photogam;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;

public class ActivitySplash extends Activity {

	private Intent intent;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.splash);

		final SharedPreferences settings = this.getSharedPreferences(
				V.PREFERENCE, MODE_PRIVATE);
		Thread splashTimer = new Thread() {
			public void run() {
				try {
					sleep(1000);
					if (!settings.contains(V.PREFERENCE_USER)) {
						intent = new Intent(ActivitySplash.this,
								PageAdapter.class);
						startActivity(intent);
					} else {
						// go to main menu
						// intent = new Intent(ActivitySplash.this,
						// ActivityLogin.class);
						// startActivity(intent);
					}
				} catch (InterruptedException e) {
					e.printStackTrace();
				} finally {
					finish();
				}
			}
		};
		splashTimer.start();
	}

	public void onPause() {
		super.onPause();
		finish();
	}
}
